/*
 * 人员信息   饼图
 */
var url = '', jsonData = '';
$(function(){
	loadData();
});

function loadData(){
	loadTopCSS();
	/**
	 * 饼图
	 */
	loadDegree();
	loadSex();
	loadAge();
	loadWorkExperience();
	 
}

function loadTopCSS() {
	$("#li2").addClass("navdown");
}

function loadDegree(){
	url = ctx + '/show/degree';
	var departmentId = $('#departmentId').val();
	jsonData = {departmentId:departmentId};
	var  returnData= commonAjax();
	initPieChart(returnData.title,returnData.degree,document.getElementById('degreeMain'));
	
}

function loadAge(){
	url = ctx + '/employeeController/ageDistribute';
	var departmentId = $('#departmentId').val();
	jsonData = {departmentId:departmentId};
	var  returnData= commonAjax();
	initPieChart(returnData.title,returnData.headcount,document.getElementById('ageMain'));
}

function loadSex(){
	url = ctx + '/show/gender';
	var departmentId = $('#departmentId').val();
	jsonData = {departmentId:departmentId};
	var  returnData= commonAjax();
	initPieChart(returnData.title,returnData.gender,document.getElementById('sexMain'));
}

function loadWorkExperience(){
	url = ctx + '/employeeController/workAgeDistribute';
	var departmentId = $('#departmentId').val();
	jsonData = {departmentId:departmentId};
	var  returnData= commonAjax();
	initPieChart(returnData.title,returnData.headcount,document.getElementById('workExperienceMain'));
}

function commonAjax(){
	var result = '';
	$.ajax({
		type: 'GET',
		data: jsonData,
	    url: url,
	    async: false,
	    dataType:"json",
	    success: function(data){
	    	result = data;
	    },
	    error: function(){
	    }
	});
	return result;
}
/**
 *  ！！！！！！！！！！！异步请求！！！！！！！！！！！！！
 */
/*function commonAjax(fun, dataType){
	$.ajax({
		type: 'POST',
		data: jsonData,
	    url: url,
	    dataType: dataType,
	    success: function(data){
	    	fun(data);
	    },
	    error: function(){
	    }
	});
}*/